/*
day258
2020.5.12
*/
#include<vector>
#include<cstdlib> 
using namespace std;

struct TreeNode {
    int val;
    TreeNode *left;
    TreeNode *right;
    TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};

class Solution {
public:
    vector<vector<int>> pathSum(TreeNode* root, int sum) {
		vector<vector<int>> res;
		vector<int> vec;
		
		help(root,sum,0,vec,res);
		return res;
    }
    
    void help(TreeNode *root,const int &target,int cur_sum,vector<int> &vec,vector<vector<int>> &res)
	{
		if(!root)
		{
			return ;
		}
		
		cur_sum+=root->val;
		vec.push_back(root->val);
		
		if(!root->left && !root->right && cur_sum==target)
		{
			res.push_back(vec);
			vec.pop_back();
			return ;
		}
		
		help(root->left,target,cur_sum,vec,res);
		help(root->right,target,cur_sum,vec,res);
		
		vec.pop_back();
		return;
	 } 
};

int main()
{
	return 0;
}
